package com.manor.main.adapter

import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.manor.common.custom.DrawableTextView
import com.manor.main.R
import com.manor.main.bean.ListBean

class VulgarItemAdapter(layoutResId: Int, data: MutableList<ListBean>?) : BaseQuickAdapter<ListBean, BaseViewHolder>
(layoutResId, data) {


    override fun convert(helper: BaseViewHolder, item: ListBean) {
        helper.run {
            helper.getView<TextView>(R.id.order).setText(item.userNiceName)
            var sun :Int = layoutPosition+3
            helper.getView<TextView>(R.id.tv_num).setText(sun.toString())
            helper.getView<TextView>(R.id.money).setText(item.totalCoin.toString())

            Glide.with(context).load(item.avatarThumb).into(helper.getView<ImageView>(R.id.avatar))
            if (item != null) {
                if (item.sex == 1) {
                    helper.getView<DrawableTextView>(R.id.tv_age) .leftDrawable = context?.getDrawable(R.mipmap.gender_nan)
                    helper.getView<LinearLayout>(R.id.ll_city_genderbg).background = context?.getDrawable(R.drawable.shape_item_city_bg)
                } else {
                    helper.getView<DrawableTextView>(R.id.tv_age) .leftDrawable = context?.getDrawable(R.mipmap.gender_nv)
                    helper.getView<LinearLayout>(R.id.ll_city_genderbg).background = context?.getDrawable(R.drawable.shape_item_city_bg)
                }
            }

            helper.getView<DrawableTextView>(R.id.tv_age).setText(item.age)
        }



    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
        return super.onCreateViewHolder(parent, viewType)

    }
}